package org.rcloud.io.service.impl;

import org.rcloud.io.Utils.PageVo;
import org.rcloud.io.Utils.ResultVo;
import org.rcloud.io.mapper.DiscoverMapper;
import org.rcloud.io.model.Discover;
import org.rcloud.io.service.DiscoverService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2019/3/31.
 */
@Service(value = "DiscoverService")
public class DiscoverServiceImpl implements DiscoverService {
    @Autowired

    private DiscoverMapper discoverMapper;


    @Override
    public ResultVo deleteByPrimaryKey(String id) {
        try {
            discoverMapper.deleteByPrimaryKey(id);
            return ResultVo.setOK(null);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }
    }

    @Override
    public ResultVo insert(Discover record) {
        if (record.equals("")||record == null) {
            return ResultVo.setError("传入的数据为空!");
        } else {
            try {
                discoverMapper.insert(record);
                return ResultVo.setOK(null);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo insertSelective(Discover record) {
        if (record.equals("")||record == null) {
            return ResultVo.setError("传入的数据为空!");
        } else {
            try {
                int i = discoverMapper.insertSelective(record);
                return ResultVo.setOK(i);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo selectByPrimaryKey(Discover record) {
        try {
            Discover discover =discoverMapper.selectByPrimaryKey(record);
            return ResultVo.setOK(discover);
        } catch (Exception e) {
            e.printStackTrace();
            return ResultVo.setError(e.getMessage());
        }
    }

    @Override
    public ResultVo updateByPrimaryKeySelective(Discover record) {
        if (record.equals("")||record == null) {
            return ResultVo.setError("传入的数据为空!");
        } else {
            try {
                discoverMapper.updateByPrimaryKeySelective(record);
                return ResultVo.setOK(null);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public ResultVo updateByPrimaryKey(Discover record) {
        if (record.equals("")||record == null) {
            return ResultVo.setError("传入的数据为空!");
        } else {
            try {
                discoverMapper.updateByPrimaryKey(record);
                return ResultVo.setOK(null);
            } catch (Exception e) {
                e.printStackTrace();
                return ResultVo.setError(e.getMessage());
            }
        }
    }

    @Override
    public PageVo<Discover> selectByid(Discover record) {
        try {
            List<Discover> list = discoverMapper.selectByid(record);
            return PageVo.setOk(list);
        } catch (Exception e) {
            e.printStackTrace();
            return PageVo.setError(e.getMessage());
        }
    }

    @Override
    public PageVo<Discover> selectAll() {
        try {
            List<Discover> list = discoverMapper.selectAll();
            return PageVo.setOk(list);
        } catch (Exception e) {
            e.printStackTrace();
            return PageVo.setError(e.getMessage());
        }
    }
}
